package com.bsi.login;

import com.bsi.core.enable.EnableCommonCore;
import com.bsi.login.oauth.handler.IOauthRequestHandler;
import com.bsi.login.oauth.handler.impl.DefaultOauthRequestHandler;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;

/**
 * @Author :liusongs
 *
 * @Import(WebMvcConfiguerEx.class)  引入此类则打开所有的扩展配置，具体请看类详情，其余新建的服务也需引入此类
 */
@SpringBootApplication(scanBasePackages={"com.bsi.login.*"})
@EnableDiscoveryClient
@EnableFeignClients
@MapperScan("com.bsi.mapper")
@EnableTransactionManagement
@EnableCommonCore
public class LoginServiceApplication {

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    @ConditionalOnMissingBean(value = IOauthRequestHandler.class)
    public IOauthRequestHandler oauthRequest() {
        return new DefaultOauthRequestHandler();
    }

    public static void main(String[] args) {
        SpringApplication.run(LoginServiceApplication.class, args);
    }

}
